import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../views/Login'
import ForgetPw from '../views/ForgetPw'
import ResetPw from '../views/ResetPw'
import Home from '../views/Home'
import Welcome from '../views/Welcome.vue'
import Self_of_s from '../views/Self_of_s'
import Class from '../views/Class'
import Review from '../views/Review'
import Search from '../views/Search'
import Approval from '../views/Approval'
import Data from '../views/Data'
import Scholarship from '../views/Scholarship'
import Fdifficulty from '../views/Fdifficulty'
import Class_dis from '../views/Class_dis'
import Class_list from '../views/class_list'
import Student_list from '../views/student_list'
import Setting from '../views/Setting'
import Mine from '../views/Mine'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/Login'
  },
  {
    path: '/Login',
    component: Login
  },
  {
    path: '/ForgetPw',
    component: ForgetPw
  },
  {
    path: '/ResetPw',
    component: ResetPw
  },
  {
    path: '/Home',
    component: Home,
    redirect: "/welcome",
    children:
      [{
        path: '/Welcome',
        component: Welcome
      },
      {
        path: '/Class',
        component: Class
      },
      {
        path: '/Self_of_s',
        component: Self_of_s
      }, {
        path: '/Class_dis',
        component: Class_dis
      }, {
        path: '/Review/Class_list',
        component: Class_list
      },
      {
        path: '/Review/Student_list',
        component: Student_list
      }, {
        path: '/Class',
        component: Class
      },
      {
        path: '/Review',
        component: Review
      },
      {
        path: '/Search',
        component: Search
      },
      {
        path: '/Approval',
        component: Approval
      },
      {
        path: '/Data',
        component: Data
      },
      {
        path: '/Scholarship',
        component: Scholarship
      },
      {
        path: '/Fdifficulty',
        component: Fdifficulty
      },
      {
        path: '/Mine',
        component: Mine
      },
      {
        path: '/Setting',
        component: Setting
      }
      ]
  }

  // {
  //   path: '/',
  //   name: 'home',
  //   component: HomeView
  // },
  // {
  //   path: '/about',
  //   name: 'about',
  //   // route level code-splitting
  //   // this generates a separate chunk (about.[hash].js) for this route
  //   // which is lazy-loaded when the route is visited.
  //   component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
  // }
]

const router = new VueRouter({
  routes
})
//导航卫士，防止未清除token直接进入主页
// router.beforeEach((to, from, next) => {
//   if (to.path == "/Login") return next();
//   const tokenStr = window.sessionStorage.getItem("token");
//   //若没有获取token，则返回登录页
//   if (!tokenStr) return next("/Login");
//   next();
// });

export default router
